home *** CD-ROM | disk | FTP | other *** search
- #import <appkit/appkit.h>
- #import "RandomIntPicker.h"
-
- @implementation RandomIntPicker
-
- - init
- {
- [self reset];
- return self;
- }
-
- - reset
- {
- count=0;
- pickedInt=0;
- return self;
- }
-
- - (int) choice
- {
- return pickedInt;
- }
-
- - (int) count
- {
- return count;
- }
-
- - insert: (int)newInt;
- {
- count++;
- if (!(random()%count)) pickedInt=newInt;
- return self;
- }
-
- @end
-
-